package com.ycw.servlet.wangwang;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;
import com.ycw.dao.ContractDao;
import com.ycw.dao.impl.ContractDaoImpl;
import com.ycw.pojo.Contract;

@WebServlet("/doAddServlet")
public class doAddServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		ContractDao cd = new ContractDaoImpl();
		String c_num = request.getParameter("c_num");
		String hid = request.getParameter("h_id");
		int h_id = Integer.parseInt(hid);
		String c_alltime = request.getParameter("c_alltime");
		String c_begintime = request.getParameter("c_begintime");
		String c_endtime = request.getParameter("c_endtime");
		String c_total = request.getParameter("c_total");
		String c_mode = request.getParameter("c_mode");
		String c_deposit = request.getParameter("c_deposit");
		String c_count = request.getParameter("c_count");
		String c_signer = request.getParameter("c_signer");
		String c_state = request.getParameter("c_state");

		Contract contract = new Contract(0, c_num, h_id, c_alltime, c_begintime, c_endtime, c_total, c_mode, c_deposit,
				c_count, c_signer, c_state);

		int bl = cd.contractAdd(contract);

		String resJSON = JSON.toJSONString(bl);
		PrintWriter out = response.getWriter();
		out.write(resJSON);
		out.close();
	}

}
